package com.hzcx.app.simplechat.model;

import android.content.Context;

import com.hzcx.app.simplechat.api.APIRequest;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.api.RxHelper;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.ui.chat.bean.ChatCollectBean;
import com.hzcx.app.simplechat.ui.home.bean.AddFriendSearchBean;
import com.hzcx.app.simplechat.util.token.TokenUtils;

import java.util.List;

/**
 * 首页相关
 */
public class HomeModel {


    /**
     * 添加好友-搜索
     *
     * @param context
     * @param search_words
     * @param observer
     */
    public static void addFriendSearch(Context context, String search_words, BaseObserver<AddFriendSearchBean> observer) {
        APIRequest
                .getRequestInterface()
                .addFriendSearch(TokenUtils.getTokenHeader(), search_words)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 收藏消息
     *
     * @param context
     * @param collectdetail
     * @param collectimage
     * @param member_id
     * @param observer
     */
    public static void addChatCollect(Context context, String collectdetail, String collectimage, int member_id, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .addChatCollect(TokenUtils.getTokenHeader(), collectdetail, collectimage, member_id)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     *  获取收藏列表
     * @param context
     * @param page
     * @param observer
     */
    public static void getChatCollectList(Context context, int page, BaseObserver<List<ChatCollectBean>> observer){
        APIRequest
                .getRequestInterface()
                .getChatCollectList(TokenUtils.getTokenHeader(),page)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     *  删除收藏
     * @param context
     * @param collect_id
     * @param observer
     */
    public static void deleteChatCollect(Context context,int collect_id,BaseObserver<BaseEmptyBean> observer){
        APIRequest
                .getRequestInterface()
                .deleteChatCollect(TokenUtils.getTokenHeader(),collect_id)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }
}
